﻿#include "MaterialSplitVectorNodeView.h"

#include "MaterialGraph/Node/MaterialGraphNodeViewModel.h"
#include "MaterialSplitVectorNodeViewModel.h"
#include "Widgets/Widget.h"

void RMaterialSplitVectorNodeView::BindViewModel(TSharedObjectPtr<RMaterialGraphNodeViewModel> InModel)
{
    Super::BindViewModel(InModel);

    SplitVectorViewModel = InModel;
}

void RMaterialSplitVectorNodeView::RegenerateContentWidget()
{
    auto OutputX=CreateSimpleOutputPinWidget(RootWidget,RootWidget,0,1);

    auto OutputY=CreateSimpleOutputPinWidget(RootWidget,RootWidget,1,2);

    auto OutputZ=CreateSimpleOutputPinWidget(RootWidget,RootWidget,2,3);

    auto Is2D=CreateCheckBoxWidget(
        RootWidget,RootWidget
        ,4
        ,[this](){
            return SplitVectorViewModel->IsSplit2DVector();
        }
        ,CString(U"二维向量")
        ,[this](bool InIsChecked){
            SplitVectorViewModel->SetSplit2DVector(InIsChecked);
        }
    );

    auto Input3DVector=CreateVector3DInputPinWidget(RootWidget,RootWidget,0,5);
    Input3DVector->Visible=[this](){
        return !SplitVectorViewModel->IsSplit2DVector();
    };

    auto Input2DVector=CreateVector2DInputPinWidget(RootWidget,RootWidget,1,5);
    Input2DVector->Visible=[this](){
        return SplitVectorViewModel->IsSplit2DVector();
    };
}
